﻿/*
 *功能：时间按钮调置函数
 */
//使用格式setTime="time"  设置日期及时间
//使用格式setTime 设置日期
function CreateTimeBtn( el )
    {
    var sElementName = el.id;
	if(!sElementName)
	    sElementName = el.name;
	    
	if(el.tagName == "INPUT" && !document.getElementById("__timebtn$_"+sElementName))
	    {
		el.style.height = "18px";
		var sclassName = "";
		var sonclick = "";
		var sHTML = "";
		//在原来的基础上调宽18象素，约5mm
		var iWidth=parseFloat(el.style.width);
		var sWidth=el.style.width+"";
		if(!isNaN(iWidth))
		    {
			if(sWidth.indexOf("mm")>0)
			    {
				el.style.width=(iWidth+5)+"mm";
			    }
			else if(sWidth.indexOf("cm")>0)
			    {
				el.style.width=(iWidth+0.5)+"cm";
			    }
			else if(sWidth.indexOf("%")<0)
			    {
				el.style.width=(iWidth+18)+"px";
			}   
		    }
		if( el.setTime == "time" )
		    {
			if(isNaN(iWidth)) el.style.width="134px";
			sonclick = "showDateAndTime('" + sElementName + "')";
		    }
		    else
		    {
			if(isNaN(iWidth)) el.style.width="105px";
			sonclick = "showDate('" + sElementName + "')";
		    }
		
		//如果控件本身指定了想要的width(通过FixWidth指定)
		if(el.FixWidth)
			{
			el.style.width = el.FixWidth;
			}
		
		//初始值获取当前时间
		if(typeof(el.GetNowTime)!="undefined")
		    {
		    if(el.value=="")
		        {
		        var bSetValue = true;
		        if(typeof(g_DocObject)!="undefined")
			        {
			        bSetValue =  g_DocObject.IsNewDoc()
			        }
		        if(bSetValue)
		            {
		            //时间从服务器端获取
		            if(el.setTime=="time")
		                el.value = Now(true);
		            else
		                el.value = ToDate(true);		            
		            }
		        }
		    }
		
		sHTML = '<span class="spanTime  PHE"><input id="__timebtn$_'+sElementName+'" type="button" value="6" class="btntime" onclick="'+sonclick+'"/></span>';
		el.insertAdjacentHTML("afterEnd",sHTML);
	    }
    }

function showDate( sElementName )
    {
 	var oIs = document.getElementsByName( sElementName );
	if( oIs.length > 0 )
	    {
	    var sInitTime = oIs[0].value;
	    if(sInitTime=="")
	        {
	        sInitTime = Now(true);
	        if(typeof(oIs[0].GotoLastMonth)!="undefined" || typeof(oIs[0].ShowLastMonth)!="undefined")
		        {
		        sInitTime = AddMonths(sInitTime, -1);
		        sInitTime = sInitTime.LeftOfLast("-") + "-01";
		        }
		    else if(typeof(oIs[0].GotoNextMonth)!="undefined" || typeof(oIs[0].ShowNextMonth)!="undefined")
		        {
		        sInitTime = AddMonths(sInitTime, 1);
		        sInitTime = sInitTime.LeftOfLast("-") + "-01";
		        }
	        }
    		        
		if(sInitTime!="")
		    {
			sInitTime=sInitTime.replace(/\-/g,"/");
			sInitTime=sInitTime.replace("年","/").replace("月","/").replace("日","");
			sInitTime=sInitTime.replace("点",":").replace("小时",":").replace("分钟",":");
			sInitTime=sInitTime.replace("时",":").replace("分",":").replace("秒","");
		    }
		
		var oInitTime = new Date(sInitTime);
		getDateString( oIs[0], oInitTime, false);
	    }
    }

function showDateAndTime( sElementName )
    {
	var oIs = document.getElementsByName( sElementName );
	if( oIs.length > 0 )
	    {
		var sInitTime = oIs[0].value;
	    if(sInitTime=="")
	        {
	        sInitTime = Now(true);
	        if(typeof(oIs[0].GotoLastMonth)!="undefined" || typeof(oIs[0].ShowLastMonth)!="undefined")
		        {
		        sInitTime = AddMonths(sInitTime, -1);
		        var sTimePart = sInitTime.RightOfLast(" ");
		        sInitTime = sInitTime.LeftOfLast("-") + "-01 " + sTimePart;
		        }
		    else if(typeof(oIs[0].GotoNextMonth)!="undefined" || typeof(oIs[0].ShowNextMonth)!="undefined")
		        {
		        sInitTime = AddMonths(sInitTime, 1);
		        var sTimePart = sInitTime.RightOfLast(" ");
		        sInitTime = sInitTime.LeftOfLast("-") + "-01 " + sTimePart;
		        }
	        }
		        
		if(sInitTime!="")
		    {
			sInitTime=sInitTime.replace(/\-/g,"/");
			sInitTime=sInitTime.replace("年","/").replace("月","/").replace("日","");
			sInitTime=sInitTime.replace("点",":").replace("小时",":").replace("分钟",":");
			sInitTime=sInitTime.replace("时",":").replace("分",":").replace("秒","");
		    }
		
		var oInitTime = new Date(sInitTime);
		getDateString( oIs[0], oInitTime, true);
	    }
    }

////////////////////////////////////////////////////////////////////////////////////////
var g_oCalendarCn=null; //日历显示窗
var g_oTarget=null; //返回选择日期的目标对象
var g_dtCurSel=null; //当前选择的日期
var g_iTimeType=1; //1显示日期,2显示时间，3显示日期时间
var g_oOldPart=null; //原选择的Part项
var g_oOldItem=null; //原选择的面板中的项目
var g_oOldButton=null; //原突起的按钮样式的对象
var g_iYearOffset=0; //点击年后的偏移
//面板显示类型定义
//var PT_CENT="century",
var PT_YEAR="year",PT_MON="month",PT_DAY="day";
var PT_HOUR="hour",PT_MINU="minute",PT_SEC="second";

var g_sCurPanelType=PT_DAY; //当前面板显示的内容

function InitCalendar(oCal)
{
	var oBody=oCal.document.body;
 	oBody.style.border = "1px solid #D0D0D0";
 	oBody.style.backgroundColor = "#52A3E2";
 	var dtToday=new Date();
 	var sHtml="<table style='border:0;width:100%;margin-top:4px;'>";
	if((g_iTimeType&1)==1){
 		sHtml+="<tr><td id='PartDate' align='center' style='width:100%;height:20px;border-bottom:1 solid #E0E0E0;'>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_YEAR+"\",true);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>3</a>"+
 	"<a href='#' id='PartY' onclick='parent.Part_Click(\""+PT_YEAR+"\")' style='border:1 solid #52A3E2;font-size:10pt;color:#ffffff;font-weight:bold;width:50px;text-align:center;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>0000年</a>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_YEAR+"\",false);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>4</a> "+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_MON+"\",true);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>3</a>"+
 	"<a href='#' id='PartM' onclick='parent.Part_Click(\""+PT_MON+"\")' style='border:1 solid #52A3E2;font-size:10pt;color:#ffffff;font-weight:bold;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>00月</a>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_MON+"\",false);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>4</a> "+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_DAY+"\",true);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>3</a>"+
 	"<a href='#' id='PartD' onclick='parent.Part_Click(\""+PT_DAY+"\")' style='border:1 solid #52A3E2;font-size:10pt;color:#ffffff;font-weight:bold;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>00日</a>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_DAY+"\",false);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>4</a>"+
 	"</td></tr>";
	}
 	if((g_iTimeType&2)==2){
 		sHtml+="<tr><td id='PartTime' align='center' style='width:100%;height:20px;'>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_HOUR+"\",true);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>3</a>"+
 	"<a href='#' id='PartH' onclick='parent.Part_Click(\""+PT_HOUR+"\")' style='border:1 solid #52A3E2;font-size:10pt;color:#ffffff;font-weight:bold;width:50px;text-align:center;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>00时</a>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_HOUR+"\",false);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>4</a> "+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_MINU+"\",true);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>3</a>"+
 	"<a href='#' id='PartN' onclick='parent.Part_Click(\""+PT_MINU+"\")' style='border:1 solid #52A3E2;font-size:10pt;color:#ffffff;font-weight:bold;width:auto;text-align:center;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>00分</a>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_MINU+"\",false);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>4</a> "+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_SEC+"\",true);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>3</a>"+
 	"<a href='#' id='PartS' onclick='parent.Part_Click(\""+PT_SEC+"\")' style='border:1 solid #52A3E2;font-size:10pt;color:#ffffff;font-weight:bold;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>00秒</a>"+
 	"<a href='#' onclick='parent.Part_Arraw(\""+PT_SEC+"\",false);' style='font-family:Marlett;font-size:9pt;color:#ffffff;border:1 solid #52A3E2;text-decoration:none;' onmouseover='parent.MMObj(this,1)' bcr='#52A3E2' onmouseout='parent.MMObj(this,0)'>4</a>"+
 	"</td></tr>";
	}
	sHtml+="<tr><td id='Panel' style='width:100%;height:206px;margin:0;padding:0;'></td></tr>"+
 	"<tr><td id='Panel2' style='width:100%;height:20px;padding-left:14px;'>"+
 	"<a href='#' onclick='parent.Panel_Today()' style='font-size:10pt;color:#00FF00;font-weight:bold;border:1 solid #52A3E2;' bcr='#52A3E2' title='"+dtToday.getFullYear()+"-"+(dtToday.getMonth()+1)+"-"+dtToday.getDate()+"' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>[今 天]</a>　"+
 	"<a href='#' onclick='parent.Panel_Ok()' style='font-size:10pt;color:#ffffff;font-weight:bold;border:1 solid #52A3E2;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>[确 定]</a>　"+
 	"<a href='#' onclick='parent.Panel_Clear()' style='font-size:10pt;color:#ffffff;font-weight:bold;border:1 solid #52A3E2;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>[清 空]</a>　"+
 	"<a href='#' onclick='parent.Panel_Close()' style='font-size:10pt;color:#ffffff;font-weight:bold;border:1 solid #52A3E2;' bcr='#52A3E2' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>[取 消]</a>"+
 	"</td></tr></table>";
 	oBody.innerHTML=sHtml;
}
//////////////////////////////////////////////////////////
//日历操作函数
//点击项目内容
function Part_Click(sType)
{
	g_sCurPanelType=sType;
	g_iYearOffset=0;
	UpdatePanel();
}
//点击项目左
//bLeft,true向前一个范围，false向后一个范围
function Part_Arraw(sType,bLeft)
{
	if(g_dtCurSel==null || isNaN(g_dtCurSel)) g_dtCurSel=new Date();
	var iSel;
	if(sType==PT_YEAR){
		iSel=g_dtCurSel.getFullYear();
		if(bLeft) iSel--;
		else iSel++;
		g_dtCurSel.setFullYear(iSel);
	}else if(sType==PT_MON){
		iSel=g_dtCurSel.getMonth();
		if(bLeft) iSel--;
		else iSel++;
		g_dtCurSel.setMonth(iSel);
	}else if(sType==PT_DAY){
		iSel=g_dtCurSel.getDate();
		if(bLeft) iSel--;
		else iSel++;
		g_dtCurSel.setDate(iSel);
	}else if(sType==PT_HOUR){
		iSel=g_dtCurSel.getHours();
		if(bLeft) iSel--;
		else iSel++;
		g_dtCurSel.setHours(iSel);
	}else if(sType==PT_MINU){
		iSel=g_dtCurSel.getMinutes();
		if(bLeft) iSel--;
		else iSel++;
		g_dtCurSel.setMinutes(iSel);
	}else if(sType==PT_SEC){
		iSel=g_dtCurSel.getSeconds();
		if(bLeft) iSel--;
		else iSel++;
		g_dtCurSel.setSeconds(iSel);
	}
	UpdatePanel();
}

//平移40年
//bUp,true向前移动40年；false向后移动40年
function Panel_Year(bUp)
{
	if(bUp) g_iYearOffset-=5;
	else g_iYearOffset+=5;
	UpdatePanel();
}
//点击面板内容
//iSign==-1表示是早一个范围
//     ==0表示是当前范围
//     ==1表示是晚一个范围
function Panel_Click(sVal,sType,iSign)
{
	if(g_dtCurSel==null || isNaN(g_dtCurSel)) g_dtCurSel=new Date();
	var iSel=parseInt(sVal);
	if(iSel<0) iSel=0;
	var iTemp;
	if(sType==PT_YEAR){
		g_dtCurSel.setFullYear(iSel);
		g_sCurPanelType=PT_MON;
	}else if(sType==PT_MON){
		if(iSign!=0){
			iTemp=g_dtCurSel.getFullYear();
			if(iSign<0) iTemp--;
			else if(iSign>0) iTemp++;
			g_dtCurSel.setFullYear(iTemp);
		}
		g_dtCurSel.setMonth(iSel-1);
		g_sCurPanelType=PT_DAY;
	}else if(sType==PT_DAY){
		if(iSign!=0){
			iTemp=g_dtCurSel.getMonth();
			if(iSign<0) iTemp--;
			else if(iSign>0) iTemp++;
			g_dtCurSel.setMonth(iTemp);
		}
		g_dtCurSel.setDate(iSel);
		if(g_iTimeType==1){
			Panel_Ok();
			return;
		}else{
			g_sCurPanelType=PT_HOUR;
		}
	}else if(sType==PT_HOUR){
		if(iSign!=0){
			iTemp=g_dtCurSel.getDate();
			if(iSign<0) iTemp--;
			else if(iSign>0) iTemp++;
			g_dtCurSel.setDate(iTemp);
		}
		g_dtCurSel.setHours(iSel);
		g_sCurPanelType=PT_MINU;
	}else if(sType==PT_MINU){
		if(iSign!=0){
			iTemp=g_dtCurSel.getHours();
			if(iSign<0) iTemp--;
			else if(iSign>0) iTemp++;
			g_dtCurSel.setHours(iTemp);
		}
		g_dtCurSel.setMinutes(iSel);
		g_sCurPanelType=PT_SEC;
	}else if(sType==PT_SEC){
		if(iSign!=0){
			iTemp=g_dtCurSel.getMinutes();
			if(iSign<0) iTemp--;
			else if(iSign>0) iTemp++;
			g_dtCurSel.setMinutes(iTemp);
		}
		g_dtCurSel.setSeconds(iSel);

		Panel_Ok();
		return;
	}
	UpdatePanel();
}
//点击清空
function Panel_Clear()
{
	g_oCalendarCn.hide();
	if(g_oTarget!=null){
		g_oTarget.value="";
		g_oTarget.focus();
	}
}
//点击确定
function Panel_Ok()
    {
	g_oCalendarCn.hide();
	if(g_oTarget!=null)
	    {
		var dtToday;
		if(g_dtCurSel==null || isNaN(g_dtCurSel)) dtToday=new Date();
		else dtToday=g_dtCurSel;
		var sDate="";
		var iVal="";
		if((g_iTimeType&1)==1)
		    {
		    var iYear  = dtToday.getFullYear();
		    var iMonth = dtToday.getMonth()+1;
		    var iDay   = dtToday.getDate();
			sDate += iYear;
			sDate += "-" + (iMonth<10 ? "0" + iMonth : iMonth);
			sDate += "-" + (iDay<10 ? "0" + iDay : iDay);
		    }
		if((g_iTimeType&2)==2)
		    {
			if(sDate!="") sDate+=" ";
			if(g_dtCurSel!=null && !isNaN(g_dtCurSel))
			    {
				iVal=g_dtCurSel.getHours();
				sDate+=iVal<10?"0"+iVal:iVal;
				iVal=g_dtCurSel.getMinutes();
				sDate+=":"+(iVal<10?"0"+iVal:iVal);
				iVal=g_dtCurSel.getSeconds();
				sDate+=":"+(iVal<10?"0"+iVal:iVal);
			    }
			else
			    {
				sDate+="00:00:00";
			    }
		    }
		g_oTarget.value=sDate;
		g_oTarget.focus();
		if(g_oTarget.onchange)
		    g_oTarget.onchange();
	    }
    }
//点击今天
function Panel_Today()
{
	g_oCalendarCn.hide();
	if(g_oTarget!=null){
		var dtToday=new Date();
		var sDate="";
		if((g_iTimeType&1)==1){
			sDate+=dtToday.getFullYear()+"-"+(dtToday.getMonth()+1)+"-"+dtToday.getDate();
		}
		if((g_iTimeType&2)==2){
			if(sDate!="") sDate+=" ";
			var iVal;
			iVal=dtToday.getHours();
			sDate+=iVal<10?"0"+iVal:iVal;
			iVal=dtToday.getMinutes();
			sDate+=":"+(iVal<10?"0"+iVal:iVal);
			iVal=dtToday.getSeconds();
			sDate+=":"+(iVal<10?"0"+iVal:iVal);
		}
		g_oTarget.value=sDate;
		g_oTarget.focus();
	}
}
//点击“取消”
function Panel_Close()
{
	g_oCalendarCn.hide();
}

function MMObj(oButton,bIn)
{
	if(g_oOldButton!=null && g_oOldButton!=oButton){
		if(g_oOldButton.bcr){
			g_oOldButton.style.borderWidth="1";
			g_oOldButton.style.borderStyle="solid";
			g_oOldButton.style.borderColor=g_oOldButton.bcr;
		}else{
			g_oOldButton.style.borderWidth="0";
			g_oOldButton.style.borderStyle="";
			g_oOldButton.style.borderColor="";
		}
	}
	if(bIn){
		g_oOldButton=oButton;
		if(g_oOldButton!=null){
			g_oOldButton.style.borderWidth="1";
			g_oOldButton.style.borderStyle="solid";
			g_oOldButton.style.borderColor="#FFFFFF #808080 #808080 #FFFFFF";
		}
	}else{
		if(oButton!=null){
			if(g_oOldButton.bcr){ //保留边框
				g_oOldButton.style.borderWidth="1";
				g_oOldButton.style.borderStyle="solid";
				g_oOldButton.style.borderColor=g_oOldButton.bcr;
			}else{
				g_oOldButton.style.borderWidth="0";
				g_oOldButton.style.borderStyle="";
				g_oOldButton.style.borderColor="";
			}
		}
		g_oOldButton=null;
	}
}
/************************************************/

function getDateString ( Obj, dtCur, bGetTime)
    {
	g_oTarget=Obj;
	g_iTimeType=bGetTime?3:1;
	g_dtCurSel=dtCur;
	g_iCentOffset=0;
	if(g_oCalendarCn==null)
	    {
		g_oCalendarCn=window.createPopup();
	    }
	InitCalendar(g_oCalendarCn);
	g_sCurPanelType=(g_iTimeType==2?PT_SEC:PT_DAY);
	UpdatePanel();
	g_oCalendarCn.show(0,Obj.offsetHeight,304,(bGetTime?290:270),Obj);
    }
    
/************************************************/

/*
	去除日期中的日期部分,留下年和月
*/
function RemoveDate(oThis)
	{
	if(Instr(oThis.value,"-"))
		{
		var sNewValue = strLeftBack(oThis.value,"-");
		if(Instr(sNewValue,"-"))
			oThis.value = sNewValue;
		}			
	}

function UpdatePanel()
{
	var dtToday=new Date();
	if(g_dtCurSel==null || isNaN(g_dtCurSel)){
		g_dtCurSel=dtToday;
	}
	var sVal="";
	if((g_iTimeType&2)==2){
		sVal=g_dtCurSel.getHours();
		if(sVal<10) sVal="0"+sVal;
		g_oCalendarCn.document.all.PartH.innerText=sVal+"时";
		sVal=g_dtCurSel.getMinutes();
		if(sVal<10) sVal="0"+sVal;
		g_oCalendarCn.document.all.PartN.innerText=sVal+"分";
		sVal=g_dtCurSel.getSeconds();
		if(sVal<10) sVal="0"+sVal;
		g_oCalendarCn.document.all.PartS.innerText=sVal+"秒";
	}
	if((g_iTimeType&1)==1){
		sVal=g_dtCurSel.getMonth()+1;
		if(sVal<10) sVal="0"+sVal;
		g_oCalendarCn.document.all.PartM.innerText=sVal+"月";
		sVal=g_dtCurSel.getDate();
		if(sVal<10) sVal="0"+sVal;
		g_oCalendarCn.document.all.PartD.innerText=sVal+"日";
		sVal=g_dtCurSel.getFullYear();
		g_oCalendarCn.document.all.PartY.innerText=sVal+"年";
	}
	var oPanel=g_oCalendarCn.document.all.Panel;
	if(g_oOldPart!=null){
		//g_oOldPart.style.border="";
		g_oOldPart.style.backgroundColor="";
	}
	var iCur,iCurY,iToday,ixp,iyp;
	var sHtml,sExp,sSel;
	if(g_sCurPanelType==PT_YEAR){
		g_oOldPart=g_oCalendarCn.document.all.PartY;
		
		iCur=g_dtCurSel.getFullYear();
		iToday=dtToday.getFullYear();
		sVal=iCur-(iCur%5)-25+g_iYearOffset;
		if(sVal<0) sVal=0;
		sHtml="<table style='width:100%;border:1px solid white;font-size:9pt;'>";
		for(ixp=0;ixp<8;ixp++){
			sHtml+="<tr style='height:20px;' bgcolor='#EFEFEF' valign='middle' align='center'>";
			if(ixp==0){
				sHtml+="<td bgcolor='#CCCCCC' bcr='#CCCCCC' style='border:1 solid #CCCCCC;color:red;width:5%;font-family:Marlett;font-size:12pt;cursor:hand;' onclick='parent.Panel_Year(true)' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>5</td>";
			}else if(ixp==7){
				sHtml+="<td bgcolor='#CCCCCC' bcr='#CCCCCC' style='border:1 solid #CCCCCC;color:red;font-family:Marlett;font-size:12pt;cursor:hand;' onclick='parent.Panel_Year(false)' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)'>6</td>";
			}else if(ixp==1){
				sHtml+="<td rowSpan=6>&nbsp;</td>";
			}
			for(iyp=0;iyp<5;iyp++){
				if(iCur==sVal) sSel="background-color:#FF0000;color:#FFFFFF;";
				else if(iToday==sVal) sSel="background-color:#45D045;";
				else sSel="";
				sHtml+="<td onclick='parent.Panel_Click("+sVal+",\""+g_sCurPanelType+"\",0)' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)' bcr='#EFEFEF' style='border:1 solid #EFEFEF;cursor:hand;"+sSel+(ixp==0?"width:19%;":"")+"'>"+sVal+"</td>";
				sVal++;
			}
			sHtml+="</tr>";
		}
	}else if(g_sCurPanelType==PT_MON){
		g_oOldPart=g_oCalendarCn.document.all.PartM;
		
		iCur=g_dtCurSel.getMonth()+1;
		iToday=dtToday.getMonth()+1;
		sVal=1;
		sHtml="<table style='width:100%;height:50%;border:1px solid white;margin-top:20px;'>";
		iCurY=g_dtCurSel.getFullYear();
		for(ixp=0;ixp<2;ixp++){
			sHtml+="<tr style='height:26px;' bgcolor='#EFEFEF' valign='middle' align='center'>";
			for(iyp=0;iyp<6;iyp++){
				if(iCur==sVal) sSel="background-color:#FF0000;color:#FFFFFF;";
				else if(iCurY==dtToday.getFullYear() && iToday==sVal) sSel="background-color:#45D045;";
				else sSel="";
				sHtml+="<td onclick='parent.Panel_Click("+sVal+",\""+g_sCurPanelType+"\",0)' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)' bcr='#EFEFEF' style='border:1 solid #EFEFEF;cursor:hand;"+sSel+(ixp==0?"width:16%;":"")+"'>"+sVal+"<font color='#A0A0A0'>月</font></td>";
				sVal++;
			}
			sHtml+="</tr>";
			if(ixp==0) sHtml+="<tr><td colspan=6 style='height:50px;background-color:#CCCCCC;'>&nbsp;</td></tr>";
		}
	}else if(g_sCurPanelType==PT_DAY){
		g_oOldPart=g_oCalendarCn.document.all.PartD;
		
		var iWeek,iSign;
		iCurY=g_dtCurSel.getMonth();
		iCur=g_dtCurSel.getDate();
		iToday=dtToday.getDate();
		
		var dtFirst=new Date(g_dtCurSel.getFullYear(),g_dtCurSel.getMonth(),1);
		iWeek=dtFirst.getDay();
		dtFirst.setDate(1-iWeek);
		sHtml="<table style='width:100%;border:1px solid white;'>"+
		"<tr style='font-size:9pt;height:18px;font-weight:bold;' bgcolor='#CCCCCC' valign='middle' align='center'><td style='width:14.29%;'>日</td><td style='width:14.29%;'>一</td><td style='width:14.29%;'>二</td><td style='width:14.29%;'>三</td><td style='width:14.29%;'>四</td><td style='width:14.29%;'>五</td><td style='width:14.29%;'>六</td></tr>";
		for(ixp=0;ixp<6;ixp++){
			sHtml+="<tr style='font-size:10pt;height:18px;' bgcolor='#EFEFEF' valign='middle' align='center'>";
			for(iyp=0;iyp<7;iyp++){
				sVal=dtFirst.getDate();
				if(iCurY!=dtFirst.getMonth()){
					if(iyp==0 || iyp==6) sExp="color:#FFAAAA;";
					else sExp="color:#CCCCCC";
				}else if(iyp==0 || iyp==6){
					sExp="color:#FF2020;";
				}else{
					sExp="";
				}
				if(iCurY==dtFirst.getMonth() && iCur==sVal){
					sSel="background-color:#FF0000;color:#FFFFFF;";
					sExp="";
				}else if(dtFirst.getMonth()==dtToday.getMonth() && iToday==sVal){
					sSel="background-color:#45D045;";
				}else{
					sSel="";
				}
				iSign=0;
				if(iCurY!=dtFirst.getMonth()){
					if(iCurY==11 && dtFirst.getMonth()==0) iSign=1;
					else if(iCurY==0 && dtFirst.getMonth()==11) iSign=-1;
					else if(dtFirst.getMonth()>iCurY) iSign=1;
					else if(dtFirst.getMonth()<iCurY) iSign=-1;
				}
				sHtml+="<td onclick='parent.Panel_Click("+sVal+",\""+g_sCurPanelType+"\","+iSign+")' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)' bcr='#EFEFEF' style='border:1 solid #EFEFEF;cursor:hand;"+sSel+sExp+"'>"+sVal+"</td>";
				dtFirst.setDate(sVal+1);
			}
		}
	}else if(g_sCurPanelType==PT_HOUR){
		g_oOldPart=g_oCalendarCn.document.all.PartH;
		
		iCur=g_dtCurSel.getHours();
		iToday=dtToday.getHours();
		sVal=0;
		sHtml="<table style='width:100%;border:1px solid white;font-size:10pt;'>";
		for(ixp=0;ixp<6;ixp++){
			if(ixp>2) sExp="#D8D8D8";
			else sExp="#EFEFEF";
			sHtml+="<tr style='height:26px;' bgcolor='"+sExp+"' valign='middle' align='center'>";
			for(iyp=0;iyp<4;iyp++){
				if(iCur==sVal) sSel="background-color:#FF0000;color:#FFFFFF;";
				else if(iToday==sVal) sSel="background-color:#45D045;";
				else sSel="";
				
				sHtml+="<td onclick='parent.Panel_Click("+sVal+",\""+g_sCurPanelType+"\",0)'' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)' bcr='"+sExp+"' style='border:1 solid "+sExp+";cursor:hand;"+sSel+(ixp==0?"width:25%;":"")+"'>"+(sVal<10?"0":"")+sVal+"<font color='#A0A0A0'>时</font></td>";
				sVal++;
			}
		}
	}else if(g_sCurPanelType==PT_MINU){
		g_oOldPart=g_oCalendarCn.document.all.PartN;
		
		iCur=g_dtCurSel.getMinutes();
		iToday=dtToday.getMinutes();
		sVal=0;
		sHtml="<table style='width:100%;border:1px solid white;font-size:10pt;'>";
		for(ixp=0;ixp<6;ixp++){
			sHtml+="<tr style='height:26px;' bgcolor='#EFEFEF' valign='middle' align='center'>";
			for(iyp=0;iyp<3;iyp++){
				if(iCur==sVal) sSel="background-color:#FF0000;color:#FFFFFF;";
				else if(iToday==sVal) sSel="background-color:#45D045;";
				else sSel="";
				
				sHtml+="<td onclick='parent.Panel_Click("+sVal+",\""+g_sCurPanelType+"\",0)' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)' bcr='#EFEFEF' style='border:1 solid #EFEFEF;cursor:hand;"+sSel+(ixp==0?"width:33.3%;":"")+"'>"+(sVal<10?"0":"")+sVal+"<font color='#A0A0A0'>分</font></td>";
				if(iyp==0) sVal+=5;
				else if(iyp==1) sVal+=4;
				else sVal+=1;
			}
		}
	}else if(g_sCurPanelType==PT_SEC){
		g_oOldPart=g_oCalendarCn.document.all.PartS;
		
		iCur=g_dtCurSel.getSeconds();
		iToday=dtToday.getSeconds();
		sVal=0;
		sHtml="<table style='width:100%;border:1px solid white;font-size:10pt;'>";
		for(ixp=0;ixp<6;ixp++){
			sHtml+="<tr style='height:26px;' bgcolor='#EFEFEF' valign='middle' align='center'>";
			for(iyp=0;iyp<3;iyp++){
				if(iCur==sVal) sSel="background-color:#FF0000;color:#FFFFFF;";
				else if(iToday==sVal) sSel="background-color:#45D045;";
				else sSel="";
				
				sHtml+="<td onclick='parent.Panel_Click("+sVal+",\""+g_sCurPanelType+"\",0)' onmouseover='parent.MMObj(this,1)' onmouseout='parent.MMObj(this,0)' bcr='#EFEFEF' style='border:1 solid #EFEFEF;cursor:hand;"+sSel+(ixp==0?"width:33.3%;":"")+"'>"+(sVal<10?"0":"")+sVal+"<font color='#A0A0A0'>秒</font></td>";
				if(iyp==0) sVal+=5;
				else if(iyp==1) sVal+=4;
				else sVal+=1;
			}
		}
	}
	sHtml+="</table>";
	oPanel.innerHTML=sHtml;

	if(g_oOldPart!=null){
		//g_oOldPart.style.border="1 solid red";
		g_oOldPart.style.backgroundColor="#FF0000";
	}
}


//选择日期
//sYear 年份
//sMonth 月份
//sSeletedDays 默认选中的日期 (日期以“；”隔开，直接采用数字表示天数即可，例如希望选中1到3号，则传入 1;2;3即可)
//sFormatType 返回日期的格式化形式  yyyy 代表年 MM 代表月 dd 代表日
//bIncludeWeek 返回的日期格式是否包含星期数据，为true时，包含星期！例如：返回如下格式的数据：2011-07-01(星期五);2011-07-02(星期六)
//返回选中的日期
function SelectDate(sYear, sMonth, sSelectedDays, sFormatType,bIncludeWeek) 
    {
    if (!sYear || !sMonth) 
        {
        alert("必须输入年份以及月份");
        return false;
        }
    var aParam = new Array();
    aParam[0] = sYear;
    aParam[1] = sMonth;
    aParam[2] = sSelectedDays;
    aParam[3] = sFormatType;
    aParam[4] = bIncludeWeek;
    var sUrl = _MyWebsite.CommonElementsFolderUrl() + "/DateTimeCtrl/SelectDate.aspx";
    var sReturn = window.showModalDialog(sUrl, aParam, "dialogHeight=320px;dialogWidth=350px;status=0;help=0;scrollbars=no; resizable=1");
    return sReturn;
    }
    